using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace FormsAnywhere.UIProcessDesigner.UIEditors
{
    public partial class SelectEntryUITypeEditorForm : Form
    {
        private string strValue;

        public SelectEntryUITypeEditorForm()
        {
            InitializeComponent();

            strValue = "";
        }

        public string Values
        {
            get { return strValue; }
            set { strValue = value; }
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtEntry.Text.Length > 0)
            {
                lbItems.Items.Add(txtEntry.Text);
                txtEntry.Text = "";
            }
        }

        private void SelectEntryUITypeEditorForm_Load(object sender, EventArgs e)
        {
            lbItems.Items.Clear();

            string[] strValues = strValue.Split(':');
            for (int nIndex = 0; nIndex < strValues.Length; nIndex++)
            {
                if (strValues[nIndex].Length > 0)
                {
                    lbItems.Items.Add(strValues[nIndex]);
                }
            }
        }

        private void btnRemove_Click(object sender, EventArgs e)
        {
            int nIndex = lbItems.SelectedIndex;
            if (nIndex < lbItems.Items.Count)
            {
                lbItems.Items.RemoveAt(nIndex);
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            StringBuilder strTemp = new StringBuilder();
            for (int nIndex = 0; nIndex < lbItems.Items.Count; nIndex++)
            {
                strTemp.Append(lbItems.Items[nIndex]);
                strTemp.Append(":");
            }

            strValue = strTemp.ToString();

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}